package structs;

/**
 * Michael Sobczak
 * mis98@pitt.edu
 * Deck.java
 */

import java.util.*;

public class Deck<T> {
    LinkedList<T> deck;

    public Deck() {
        deck = new LinkedList();
    }

    public void shuffle() {
        LinkedList<T> shuffleList = new LinkedList();
        while (!deck.isEmpty()) {
            int removalIndex = (int)(Math.random() * deck.size());
            shuffleList.add(deck.remove(removalIndex));
        }
        deck = shuffleList;
    }

    public T draw() {
        return deck.removeFirst();
    }

    public void add(T item) {
        deck.addLast(item);
    }
}
